/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import protocol.TSFile;
import protocol.TSFileTag;

/**
 *
 * @author Flavio
 */
public class TestPoolThread {

    public static void main(String [] args){
        try {
            PoolThreads pool = new PoolThreads(1, 0);

            TSFile f12 = new TSFile(new TSFileTag(14, 1028));
            
            byte[] data = new byte[]{(byte)'a', (byte)'b', (byte)'c', (byte)'d'};
            Tupple novo = new Tupple(14, data);
            
            pool.addTSFile(f12);
            Thread.currentThread().sleep(2000);
            pool.execute(12, data);

            pool.removeWorkerWriter();
            /*
            Thread.currentThread().sleep(1000);
            TSFile f14 = new TSFile(14);
            f14.openFile();
            System.out.println(f14.getFileTag().toString());
            byte[] buffer = null;
            while((buffer = f14.read())!=null){
                String teste = new String(buffer);
                System.out.println("Buffer: "+buffer.length);
                System.out.println(teste);
            }
            f14.close();
            File f = new File("14");
            f.delete();*/
            
        }
        catch (InterruptedException ex) {
            Logger.getLogger(TestPoolThread.class.getName()).log(Level.SEVERE, null, ex);
        }        catch (IOException ex) {
            Logger.getLogger(TestPoolThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
